import { formatHeader } from 'plugins/utils.js'
import { Notify } from 'quasar'

export function headerSuccess (state, payload) {
  let header = JSON.parse(payload)
  state.columns = formatHeader(header)
}

export function loadTableSuccess (state, payload) {
  state.tableData = payload.results
  state.serverPagination.rowsNumber = payload.count
  state.loading = false
}

export function openNewPublish (state, payload) {
  state.newPublishDialog = true
  state.pid = payload.toString()
}

export function showHost (state, payload) {
  Notify.create({
    icon: 'tag_faces',
    position: 'top',
    color: 'tertiary',
    message: payload.toString()
  })
}

export function openPublish (state, payload) {
  state.pubId = payload.toString()
  state.verifyDialog = true
}

export function openGrayPublish (state, payload) {
  state.pubId = payload.toString()
  state.grayDialog = true
}

export function openPubInfo (state, payload) {
  state.pubId = payload.toString()
  state.infoDialog = true
}

export function openRestartService (state, payload) {
  state.pid = payload.toString()
  state.restartServiceDialog = true
}

export function openFileReplace (state, payload) {
  state.pid = payload.toString()
  state.fileReplaceDialog = true
}
